
class Shape{
    var no=0
    
    //0x000340
    final func show(){
        print("Shape.show")
    }
    
    //0x000640
    func move() {
        print("Shape.move")
    }
}


class Rectangle: Shape{
    
    override var no: Int {
        get{
            print("Rectangle.no.get()")
            return super.no
        }
        set{
            print("Rectangle.no.set()")
            super.no=newValue
            
        }
    }
    
    //0x000880
    override func move() {
        print("Rectangle.move")
    }
    
}


class Circle: Shape{
    override func move() {
        print("Circle.move")
    }
}

func process(shape: Shape){
    shape.no++
    shape.move() //根据实际类型来调用
}

//变量有双重身份：
//1. 声明类型
//2. 实际类型
var sp: Shape
sp=Shape()
sp.move() // JMP  GetVirtualMethod(sp) 二次指针间接运算
sp.show() // JMP  0x000340

sp=Rectangle()
sp.move() // JMP  GetVirtualMethod(sp) 二次指针间接运算
process(sp)

sp=Circle()
sp.move()
process(sp)




